import java.util.Arrays;

public class Leetcode2335 {

    public int fillCups(int[] amount) {
        Arrays.sort(amount);

        if (amount[0] + amount[1] < amount[2]) {
            return amount[2];
        }

        return (amount[0] + amount[1] + amount[2] + 1) / 2;
    }

    public int fillCups1(int[] amount) {
        int res = 0;
        while (amount[0] != 0 && amount[1] != 0 && amount[2] != 0) {
            Arrays.sort(amount);
            amount[2]--;
            amount[1]--;
        }

        return res;
    }
}
